/*
 * Copyright 2009 Prime Technology.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.primefaces.facestrace;

import java.util.ArrayList;
import java.util.List;

import javax.faces.event.PhaseId;

import org.primefaces.facestrace.phase.PhaseData;
import org.primefaces.facestrace.utils.TraceConstants;

public class TraceData {

	protected PhaseData[] phases;
	
	private Integer phaseNoCausedResponse;
	
	private List logs;

	public TraceData() {
		initPhases();
		logs = new ArrayList();
	}
	
	private void initPhases() {
		phases = new PhaseData[6];
		phases[0] = new PhaseData(PhaseId.RESTORE_VIEW, TraceConstants.PHASE_RESTORE_VIEW_NAME);
		phases[1] = new PhaseData(PhaseId.APPLY_REQUEST_VALUES, TraceConstants.PHASE_APPLY_REQUEST_VALUES_NAME);
		phases[2] = new PhaseData(PhaseId.PROCESS_VALIDATIONS, TraceConstants.PHASE_PROCESS_VALIDATIONS_NAME);
		phases[3] = new PhaseData(PhaseId.UPDATE_MODEL_VALUES, TraceConstants.PHASE_UPDATE_MODEL_NAME);
		phases[4] = new PhaseData(PhaseId.INVOKE_APPLICATION, TraceConstants.PHASE_INVOKE_APPLICATION_NAME);
		phases[5] = new PhaseData(PhaseId.RENDER_RESPONSE, TraceConstants.PHASE_RENDER_RESPONSE_NAME);
		phases[0].setExecuted(true);		//Restore view is always executed
		phases[5].setExecuted(true);		//Response is always executed
	}

	public PhaseData[] getPhases() {
		return phases;
	}

	public void setPhases(PhaseData[] phases) {
		this.phases = phases;
	}

	public void setPhaseData(int i, PhaseData phaseData) {
		phases[i] = phaseData;
	}
	
	public Integer getPhaseNoCausedResponse() {
		return phaseNoCausedResponse;
	}
	
	public void setPhaseNoCausedResponse(Integer phaseNoCausedResponse) {
		this.phaseNoCausedResponse = phaseNoCausedResponse;
	}
	
	public List getLogs() {
		return logs;
	}
	
	public void setLogs(List logs) {
		this.logs = logs;
	}
}